package com.x.Part1_继承Thread类实现多线程;

/**
 * ClassName: PrintNumber
 * Package: IntelliJ IDEA
 * Description:
 * Written by HanXu
 * Create 2024.03.24 21:33
 */
public class PrintTest {
    public static void main(String[] args) {

        /**
         * 创建Thread的匿名子类的匿名对象，通过start()调用重写的run()方法
         */
        new Thread(){
            @Override
            public void run(){
                for(int i=0;i<10000;i++){
                    if(i%2 == 0)
                        System.out.println(Thread.currentThread().getName() +"**>"+ i);
                }
            }
        }.start();

        new Thread(){
            @Override
            public void run(){
                for(int i=0;i<10000;i++){
                    if(i%2 != 0)
                        System.out.println(Thread.currentThread().getName() +"-->"+ i);
                }
            }
        }.start();


    }
}
